Skip to content

fix(rivetkit): surface native sqlite kv errors to callers#4645

Open
NathanFlurry wants to merge 1 commit intofix/prevent-sleep-db-racesfrom
fix/surface-native-sqlite-kv-errors
Open

fix(rivetkit): surface native sqlite kv errors to callers#4645
NathanFlurry wants to merge 1 commit intofix/prevent-sleep-db-racesfrom
fix/surface-native-sqlite-kv-errors

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Copy Markdown
Member Author

NathanFlurry commented Apr 13, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown

claude bot commented Apr 13, 2026

PR Review: fix(rivetkit): surface native sqlite kv errors to callers

Overview: This PR improves debuggability of native SQLite KV failures by enriching I/O-related SQLite errors with the underlying KV channel error. The approach is clean and targeted.

Code Quality - Strengths: (1) enrichNativeDatabaseError has a never return type, ensuring TypeScript knows catch branches always terminate - important for the exec wrapper where result must be definitively assigned. (2) The deduplication guard prevents double-appending. (3) takeLastKvError uses optional chaining appropriately as a best-effort diagnostic path, per CLAUDE.md guidance. (4) Error message mutation preserves the original stack trace.

Minor Issues: (1) Incomplete test coverage - tests only exercise the run path; exec and query have no coverage. Consider adding a test for query to verify the pattern holds. (2) Narrow I/O error regex - the pattern may miss other SQLite I/O codes like SQLITE_IOERR_READ or disk full errors; a short comment on what the regex intends to catch would help future maintainers. (3) Unfilled PR description - the checklist and test description sections are blank.

Correctness: No issues found. enrichNativeDatabaseError always throws (never), so post-try/catch code is only reachable on success. The KV error is only attached when both the SQLite error is I/O-related AND a KV error exists. The optional takeLastKvError interface extension is non-breaking.

Summary: Clean, well-scoped fix. Two suggestions before merge: (1) add test coverage for exec or query paths, (2) add a brief comment on the regex scope. Everything else looks good.

Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant